package com.simen.downloader;

import com.simen.downloader.util.Utils;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.ObjectInputStream;

/**
 * Created by zhangming on 16/5/12.
 */
final class DownloadHelper {

    public static Object getFileWriter(File file) {
        if (!Utils.fileExist(file)) {
            return null;
        }

        try {
            ObjectInputStream objectInputStream = new ObjectInputStream(new FileInputStream(file));
            try {
                return objectInputStream.readObject();
            } catch (ClassNotFoundException e) {
                e.printStackTrace();
            } finally {
                if (objectInputStream != null) {
                    objectInputStream.close();
                }
            }
        } catch (IOException e) {
            e.printStackTrace();
        }

        return null;
    }
}
